package com.epidemic.project.system.kuang.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.epidemic.project.system.kuang.domain.SysTeShuQingKuang;
import com.epidemic.project.system.kuang.service.ISysTeShuQingKuangService;
import com.epidemic.framework.web.controller.BaseController;
import org.springframework.stereotype.Controller;
import com.epidemic.framework.web.domain.AjaxResult;
import com.epidemic.common.utils.poi.ExcelUtil;
import com.epidemic.framework.web.page.TableDataInfo;

/**
 * 特殊情况Controller
 *
 * @author sys
 * @date 2023-02-01
 */
@Controller
@RequestMapping("/system/kuang")
public class SysTeShuQingKuangController extends BaseController
{
    private String prefix = "system/kuang";

    @Autowired
    private ISysTeShuQingKuangService sysTeShuQingKuangService;

    @GetMapping()
    public String kuang()
    {
        return prefix + "/kuang";
    }

    /**
     * 查询特殊情况列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysTeShuQingKuang sysTeShuQingKuang)
    {
        startPage();
        List<SysTeShuQingKuang> list = sysTeShuQingKuangService.selectSysTeShuQingKuangList(sysTeShuQingKuang);
        return getDataTable(list);
    }

    /**
     * 导出特殊情况列表
     */
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysTeShuQingKuang sysTeShuQingKuang)
    {
        List<SysTeShuQingKuang> list = sysTeShuQingKuangService.selectSysTeShuQingKuangList(sysTeShuQingKuang);
        ExcelUtil<SysTeShuQingKuang> util = new ExcelUtil<SysTeShuQingKuang>(SysTeShuQingKuang.class);
        return util.exportExcel(list, "kuang");
    }

    /**
     * 新增特殊情况
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存特殊情况
     */
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysTeShuQingKuang sysTeShuQingKuang)
    {
        return toAjax(sysTeShuQingKuangService.insertSysTeShuQingKuang(sysTeShuQingKuang));
    }

    /**
     * 修改特殊情况
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysTeShuQingKuang sysTeShuQingKuang = sysTeShuQingKuangService.selectSysTeShuQingKuangById(id);
        mmap.put("sysTeShuQingKuang", sysTeShuQingKuang);
        return prefix + "/edit";
    }

    /**
     * 修改保存特殊情况
     */
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysTeShuQingKuang sysTeShuQingKuang)
    {
        return toAjax(sysTeShuQingKuangService.updateSysTeShuQingKuang(sysTeShuQingKuang));
    }

    /**
     * 删除特殊情况
     */
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysTeShuQingKuangService.deleteSysTeShuQingKuangByIds(ids));
    }
}
